<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>招聘场次</title>
  <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
  <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

  <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
  <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

  <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
  <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
  <h1>招聘场次列表</h1>
  <!--  工具栏-->
  <div class="row">
    <div class="col-md-6">
      <!-- 搜索框 -->
      <form th:action="@{/changci/search}" method="post" class="navbar-form navbar-left" role="search">
        <div class="input-group">
          <input type="text" name="keyword" class="form-control" placeholder="功能暂未实现..."/>
          <span class="input-group-btn">
            <button class="btn btn-default" type="submit">
              <span class="glyphicon glyphicon-search"></span>
            </button>
          </span>
        </div>
      </form>
    </div>
    <div class="col-md-6 text-right">
      <!-- 新增按钮 -->
      <a href="/changci/add" class="btn btn-primary">新增招聘场次</a>
    </div>
  </div>

  <div class="table-responsive">
    <table class="table table-striped table-bordered">
      <thead>
        <tr>
          <th>ID</th>
          <th>场次名称</th>
          <th>描述</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr th:each="changci : ${changcis}">
          <td th:text="${changci.id}"></td>
          <td th:text="${changci.name}"></td>
          <td th:text="${changci.description}"></td>
          <td>
            <a th:href="@{/changci/edit(id=${changci.id},page=${currentPage})}" class="btn btn-primary">编辑</a>
            <a th:href="@{/changci/delete(id=${changci.id},page=${currentPage})}" class="btn btn-danger">删除</a>
            <a th:href="@{/job/list(changCiId=${changci.id})}" class="btn btn-success">岗位</a>
            <a th:href="@{/preExaminee/list(changCiId=${changci.id})}" class="btn btn-success">预报名考生</a>
            <a th:href="@{/examinee/list(changCiId=${changci.id})}" class="btn btn-success">确认报名考生</a>
            <a th:href="@{/examinee/list(changCiId=${changci.id})}" class="btn btn-success">录取考生</a>
          </td>
        </tr>
      </tbody>
    </table>
  </div>

  <div class="text-center">
    <ul class="pagination">
      <li th:class="${currentPage == 1} ? 'disabled'">
        <a type="button" th:href="@{/changci/list(page=1)}">首页</a>
      </li>

      <!-- 显示第一页 -->
      <li th:class="${currentPage == 1} ? 'active'">
        <a th:href="@{/changci/list(page=1)}">1</a>
      </li>

      <!-- 前省略号：当左边有隐藏页码时显示 -->
      <li th:if="${currentPage - 3 > 1}" class="disabled">
        <span>...</span>
      </li>

      <!-- 中间页码生成逻辑（1-based） -->
      <li th:each="page : ${#numbers.sequence(
            (totalPages <= 5) ? 2 : (currentPage > 3 ? currentPage - 2 : 2),
            (totalPages <= 5) ? (totalPages - 1) : (currentPage < (totalPages - 2) ? currentPage + 2 : totalPages - 1)
        )}"
          th:class="${page == currentPage} ? 'active'"
          th:if="${totalPages > 1}">
        <a th:href="@{/changci/list(page=${page})}" th:text="${page}"></a>
      </li>

      <!-- 后省略号：当右边有隐藏页码时显示 -->
      <li th:if="${currentPage + 3 < totalPages}" class="disabled">
        <span>...</span>
      </li>

      <!-- 显示最后一页（总页数>1时显示） -->
      <li th:if="${totalPages > 1}" th:class="${currentPage == totalPages} ? 'active'">
        <a th:href="@{/changci/list(page=${totalPages})}" th:text="${totalPages}"></a>
      </li>

      <li th:class="${currentPage == totalPages} ? 'disabled'">
        <a type="button" th:href="@{/changci/list(page=${totalPages})}">尾页</a>
      </li>
    </ul>
  </div>
</div>
<!--  在最下面引入页脚-->
<div th:replace="~{common/footer :: footer}"></div>
</body>
</html>